unit CadVeiculoParado;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TemplateMD, AppEvnts, DB, ComCtrls, Buttons, ToolWin, Grids,
  DBGrids, StdCtrls, ExtCtrls, JvExControls, JvComponent, JvXPCore,
  JvXPButtons, Menus;

type
  TFormCadVeiculoParado = class(TFormTemplateMD)
    Panel1: TPanel;
    Edit1: TEdit;
    DBGrid1: TDBGrid;
    Label1: TLabel;
    JvXPButton1: TJvXPButton;
    Panel2: TPanel;
    Label2: TLabel;
    Edit2: TEdit;
    JvXPButton2: TJvXPButton;
    DBGrid2: TDBGrid;
    procedure FormShow(Sender: TObject);
    procedure PageControlChange(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
    procedure DBGrid2DblClick(Sender: TObject);
    procedure JvXPButton1Click(Sender: TObject);
    procedure JvXPButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormCadVeiculoParado: TFormCadVeiculoParado;

implementation

uses Template, DMS, Geral, CadVeiculoParado2;

{$R *.dfm}

procedure TFormCadVeiculoParado.FormShow(Sender: TObject);
begin
    SetaDataset(dsPrincipal,DMSr.QueryVeiculoRodando);
    SetaDataset(dsDetalhe,DMSr.QueryVeiculoParado);
  inherited;
    ToolBar1.Visible := False;
    dsPrincipal.DataSet.Open;
    dsDetalhe.DataSet.Open;
end;

procedure TFormCadVeiculoParado.PageControlChange(Sender: TObject);
begin
  {inherited;}

end;

procedure TFormCadVeiculoParado.DBGrid1DblClick(Sender: TObject);
begin
  inherited;
    if not Assigned(FormCadVeiculoParado2) then
        FormCadVeiculoParado2 := TFormCadVeiculoParado2.Create(self);
    FormCadVeiculoParado2.Mostrar(dsPrincipal.DataSet.FieldByName('codveiculo').AsString, 'I');
    FreeAndNil(FormCadVeiculoParado2);
    dsPrincipal.DataSet.Refresh;
    dsDetalhe.DataSet.Refresh;
end;

procedure TFormCadVeiculoParado.DBGrid2DblClick(Sender: TObject);
begin
  inherited;
    if not Assigned(FormCadVeiculoParado2) then
        FormCadVeiculoParado2 := TFormCadVeiculoParado2.Create(self);
    FormCadVeiculoParado2.Mostrar(dsDetalhe.DataSet.FieldByName('codveiculo').AsString, 'A');
    FreeAndNil(FormCadVeiculoParado2);
    dsPrincipal.DataSet.Refresh;
    dsDetalhe.DataSet.Refresh;
end;

procedure TFormCadVeiculoParado.JvXPButton1Click(Sender: TObject);
begin
  inherited;
    dsPrincipal.DataSet.Locate('placa',Edit1.Text,[]);
end;

procedure TFormCadVeiculoParado.JvXPButton2Click(Sender: TObject);
begin
  inherited;
    dsDetalhe.DataSet.Locate('placa',Edit2.Text,[]);
end;

end.
